define(function(require, exports, module){
	var smartgroupTemp = require("text!../template/smartgroup.html");

	module.exports = Nuui.View.extend({

		template:smartgroupTemp,

		onRender:function(){
			var view = this;
			view.$('.smart-title a').on('tap', function(){
				var self = $(this);
				
				self.addClass('at-active').siblings().removeClass('at-active');
				querySmartGroupList();
				return false;
			});
			var querySmartGroupList=function(){
				App.request(App.server.getServePath(App.path.smartGroupAction), {
				//data:"",
				success:function(data){

					if(data.ec){
						alert(data.em);
						
					}else{
						view.$(".smart-content").empty();
						var targetItem=view.$('.smart-title a.at-active h2').attr('data-code');
//						var personLists = data.smartGroupList.IndustryExperts.list;
						var personLists = data.smartGroupList[targetItem].list;
						var parentCode=data.smartGroupList[targetItem].menuCode;
						for(var item=0;item< personLists.length;item++){
							var html='';
							html+='';
							html+='<ul  data-id="'+personLists[item].id+'"  data-code="'+parentCode+'" style="float:left;width:50%;">';
						
							html+='<li style="width:100%;">	';
							html+='<img src="images/img/'+personLists[item].avatar+'" alt="" />';
							if(personLists[item].status==1){
							html+='<div class="ovfl-h fond active">';
							
							html+='	<span >'+personLists[item].name+'</span><a><img src="images/img/ai.png" alt="" /></a>';
								
							}else{
								html+='<div class="ovfl-h fond ">';
							html+='	<span class="">'+personLists[item].name+'</span><a><img src="images/img/aijia.png" alt="" /></a>';
								
							}

								
							html+='</div>';
							html+='<p>'+personLists[item].position+'</p>';
							html+='</li>';
							html+='</ul>';
							view.$(".smart-content").append(html);
						}
						
						// $(".avatar img").attr("src",userInfo.photo);
					}
				}
				});
			}
			
			querySmartGroupList();
			
			
			var photo = App.storage.get("photo");
			if(photo){
				this.$(".avatar img").attr("src", "data:image/png;base64," + photo);
			}
			
			
			
		},

		onShow:function(){
			var view=this;
			view.$('#smartGroupList ').on('tap','ul .fond img',function(e){
				e.stopPropagation();
				e.cancelBubble=true;
				if($(this).closest('.fond').hasClass('active')){
					$(this).attr('src','images/img/aijia.png');
					Nuui.utils.toast("取消关注",{'title':''});
					$(this).closest('.fond').removeClass('active');
				}else{
					$(this).attr('src','images/img/ai.png');
						Nuui.utils.toast("关注成功",{'title':''});
					$(this).closest('.fond').addClass('active');
				}
			})
			
			view.$('#smartGroupList').on('tap','ul',function(){
				var targetCode=$(this).attr('data-code');
				var targetId=$(this).attr('data-id');
 				App.storage.set('smartGroupMenuCode',targetCode);
 				App.storage.set('smartGroupListId',targetId);
				App.navigate("example/index/thinktankdetails", true);
						return false;
			})
		},


	});
});
